<div class="contextual">
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
</div>

<h2><%=l(:label_project_plural)%></h2>

<% form = form_tag({}, :onsubmit => 'selectAllOptions("selected_columns");', :method => :get, :id => 'project_list_form') do %>
<fieldset><legend><%= l(:label_filter_plural) %></legend>
<label for='status'><%= l(:field_status) %> :</label>
<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.onsubmit(); this.form.submit(); return false;" %>
<label for='name'><%= l(:label_project) %>:</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
</fieldset>

  <fieldset class="collapsible collapsed">
    <legend onclick="toggleFieldset(this);"><%= l(:field_column_names) %></legend>
    <div style="display: none;">
      <%= render(:partial => 'custom_fields/columns', :locals => { :object => Project }) %>
    </div>
  </fieldset>

  <%= hidden_field_tag('save', '') %>

  <p class="buttons hide-when-print">
    <% if defined? observe_field %>
      <% project_list_form = "$('project_list_form')" %>
    <% else %>
      <% project_list_form = "$('#project_list_form')[0]" %>
    <% end %>
    <%= link_to_function(l(:button_apply), "var project_list_form = #{project_list_form}; project_list_form.onsubmit(); project_list_form.submit();", :class => 'icon icon-checked') %>
    <%= link_to(l(:button_clear), { :controller => 'admin', :action => 'projects' }, :class => 'icon icon-reload') %>
    <%= link_to_function(l(:button_save), "var project_list_form = #{project_list_form}; project_list_form['save'].value = '1'; project_list_form.onsubmit(); project_list_form.submit();", :class => 'icon icon-save') %>
  </p>

<% end %>
<%= form if Rails::VERSION::MAJOR >= 3 %>

<div class="autoscroll">
<table class="list projects-listing">
  <thead><tr>
    <% @list_settings.columns.each do |column| %>
      <th><%= h(column.caption) %></th>
    <% end %>
  <th></th>
  </tr></thead>
  <tbody>
<% project_tree(@projects) do |project, level| %>
  <tr class="<%= cycle("odd", "even") %> <%= project.respond_to?(:css_classes) ? project.css_classes : css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
    <% @list_settings.columns.each do |column| %>
      <td class="<%= h(column.css_classes) %>" align="<%= h(column.align) %>"><%= extended_column_content(column, project) %></td>
    <% end %>
  <td class="buttons">
    <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
    <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %>
    <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
    <%= link_to(l(:button_delete), project_destroy_confirm_path(project), :class => 'icon icon-del') %>
  </td>
  </tr>
<% end %>
  </tbody>
</table>
</div>

<% html_title(l(:label_project_plural)) -%>
